﻿Public Class town
    Private time As Integer
    ' Const afternoon As Integer = 0
    ' Const noon As Integer = 1
    ' Const morning As Integer = 2
    ' Const night As Integer = 3
    Dim chooseplace As New Rectangle(350, 230, 20, 20)
    'choose point  is a rectangle
    Dim choose As New Region(chooseplace)

    Dim number As Integer
    'draw the choose point step by step
    Dim surfuce As Graphics
    'draw the choose point->surfuce
    Private Property current() As Integer
        Get
            Return time
        End Get
        Set(ByVal value As Integer)
            time = value Mod 4
        End Set
    End Property
    Private Sub screenRefresh()

        Me.screen.Refresh()
        surfuce = Me.screen.CreateGraphics
    End Sub
    Private Sub showpicture()
        Select Case time
            Case 0
                Me.screen.Image = My.Resources.Town_01
                screenRefresh()
            Case 1
                Me.screen.Image = My.Resources.Town_01
                screenRefresh()
            Case 2
                Me.screen.Image = My.Resources.Town_02
                screenRefresh()
            Case 3
                Me.screen.Image = My.Resources.Town_03
                screenRefresh()
        End Select

    End Sub

    Private Sub screen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles screen.Click

    End Sub

    Private Sub screen_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles screen.MouseUp
        If choose.IsVisible(e.X, e.Y) AndAlso Not time = 3 Then
            Collage1.time = Me.time
            Collage1.collage_Load(Nothing, Nothing)
            Collage1.Show()
            current = current + 1
            showpicture()
        ElseIf time = 3 Then
            MessageBox.Show("晚上好！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
            current = current + 1
            showpicture()
        End If
      
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Collage1.Visible = False Then
            Dim ran As New Random
            Select Case number
                Case 0
                    surfuce.DrawImage(My.Resources.anniu, chooseplace)
                Case 1
                    surfuce.DrawImage(My.Resources.anniu2, chooseplace)
                Case 3
                    surfuce.DrawImage(My.Resources.anniu4, chooseplace)
                Case 5
                    surfuce.DrawImage(My.Resources.anniu5, chooseplace)
                Case 7
                    surfuce.DrawImage(My.Resources.anniu6, chooseplace)
            End Select
            number += 1
            number = number Mod 8
        End If
    End Sub

    Private Sub town_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        screenRefresh()
        Me.Show()
    End Sub
End Class
